home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Java for 3D & VRML Worlds
/
Java for 3d and VRML Worlds.iso
/
examples
/
chap04
/
Car.java
< prev
next >
Wrap
Text File
|
1996-09-20
|
972b
|
37 lines
//
// a car running on the street.
// you get on/off the car by clicking it.
//
import vrml.*;
import vrml.node.*;
import vrml.field.*;
public class Car extends Script{
SFBool bindCarViewpoint;
SFBool bindDefaultViewpoint;
boolean onCar = false;
public void initialize(){
// get the reference of the event out 'bindCarViewpoint'.
bindCarViewpoint = (SFBool)getEventOut("bindCarViewpoint");
// get the reference of the event out 'bindDefaultViewpoint'.
bindDefaultViewpoint = (SFBool)getEventOut("bindDefaultViewpoint")
;
}
public void processEvent(Event e){
if(e.getName().equals("touched") == true){
// toggle the state.
onCar = !onCar;
if(true == onCar){
bindCarViewpoint.setValue(true);
}else{
bindDefaultViewpoint.setValue(true);
}
}
}
}